﻿/* tslint:disable:jsdoc-format */
// warning: Generated code! Do not change!
module App {
	"use strict";
	export class AjaxHelper {
		private $http: angular.IHttpService;

		constructor(public baseUrl: string) {
			this.$http = angular.injector(["ng"]).get("$http");
			if (baseUrl.match(/\/$/)) {
				baseUrl += "/";
			}
		}

		request<T>(url: string, httpVerb: string, data?: any): angular.IPromise<T> {
			var config: ng.IRequestConfig = {
				url: this.baseUrl + url,
				cache: false,
				method: httpVerb
			};

			if (data) {
				config.data = data;
			}
			return this.$http(config).then((response: angular.IHttpPromiseCallbackArg<{}>) => {
				return response.data;
			});
		}
	}

	export class ValuesProxy {
		constructor(public baseUrl: string = "") { }

		Get(): angular.IPromise<Array<string>> {
			return new AjaxHelper(this.baseUrl).request<Array<string>>("api/values/Get", "GET");
		}

		GetById(id: number): angular.IPromise<string> {
			return new AjaxHelper(this.baseUrl).request<string>("api/values/Get?id=" + id, "GET");
		}

		Post(/** [FromBody] **/value: string): angular.IPromise<void> {
			return new AjaxHelper(this.baseUrl).request<void>("api/values/Post", "POST", JSON.stringify(value));
		}

		PutById(id: number, /** [FromBody] **/value: string): angular.IPromise<void> {
			return new AjaxHelper(this.baseUrl).request<void>("api/values/Put?id=" + id, "PUT", JSON.stringify(value));
		}

		DeleteById(id: number): angular.IPromise<void> {
			return new AjaxHelper(this.baseUrl).request<void>("api/values/Delete?id=" + id, "DELETE");
		}
	}
}